function setLeftMenu(url,itemid){
	var c=$(parent.document).children()[0];
	var frameset=$(c).children()[1];
	var menuFrame=$(frameset).children()[0];
	
	$(menuFrame).load(function(){
		setLeftMenuItem(itemid);
	});
	
	menuFrame.setAttribute("src",url)
}

function setLeftMenuItem(itemId){
	var c=$(parent.document).children()[0];
	var frameset=$(c).children()[1];
	var menuFrame=$(frameset).children()[0];
	
	var d=menuFrame.contentWindow.document;
	$(d).find("a").each(function(i){
		if($(this).attr("id")==itemId){
			$(this).addClass("menuItem");
		}else{
			$(this).removeClass("menuItem");
		}
	});
}


function setLeftMenuStyle(){
	$('.menu').each(function(i){
		$(this).bind('click',function(){
			$('.menuItem').each(function(i){
				$(this).removeClass("menuItem");
			});
			$(this).addClass("menuItem");
		});
	});
}

$(document).ready(function(){
	rowStyleClass();
	setLeftMenuStyle();
	$.ajaxSetup({cache:false});
});

function rowStyleClass(){
	var i=0;
	$('.rowClass').each(function(i){
		if(i%2==0){
			$(this).removeClass('rowOdd');
			$(this).addClass('rowEven');
		}else{
			$(this).removeClass('rowEven');
			$(this).addClass('rowOdd');
		}
		$(this).mouseover(function(){
			$(this).css("background","#eee");
		});
		$(this).mouseout(function(){
			$(this).css("background","");
		});
	});
}

function listDefaultPageAjax(id,form,action){
	
	
	var submitButton=$.find("input[ajaxSearchBtn='true']")[0];
	$(submitButton).bind('click',{'gotopage':33},searchDataByPage);
	
	
	$(document).ready(function(){
		$('body').append($("<input style='display: none;' type='hiden' value='"+form+"' id='searchFormIdValue'/>"));
		$('body').append($("<input style='display: none;' type='hiden' value='"+action+"' id='searchFormActionValue'/>"));
		$('body').append($("<input style='display: none;' type='hiden' value='"+id+"' id='displayDataIdValue'/>"));
		searchDataByPage(1);
	});
}

function searchDataByPage(objParam){
	
	
	var param="0="+new Date().getMilliseconds()+"&";
	var submitFormId=$('#searchFormIdValue').val();
	var showDataId=$('#displayDataIdValue').val();
	var formAction=$('#searchFormActionValue').val();
	
	if(submitFormId){
		param+=$('#'+submitFormId).serialize();
	}
	
	var gotopage=1;
	if(objParam.hasOwnProperty("data")){
		gotopage=objParam.data.gotopage;
	}else{
		gotopage=objParam;
	}
	
	var pagesize=10;
	if($('#page_pagesize').val()){
		pagesize=$('#page_pagesize').val();
	}
	
	param+='&gotopage='+gotopage+"&pagesize="+pagesize;
	
	var loading=new ol.loading({id:showDataId});
	loading.show();
	
	$("#"+showDataId).load(formAction+"?"+param,null,function(){
		loading.hide();
		rowStyleClass();
	});
	
}


